package com.seagox.desk.auth.controller;

import com.seagox.desk.auth.serivce.IAuthService;
import com.seagox.desk.remote.entity.BaseUser;
import com.seagox.desk.remote.service.IVersionRecordService;
import com.seagox.desk.util.IpUtils;
import com.seagox.desk.common.ResultData;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 认证
 */
@RestController
@RequestMapping("/auth")
public class AuthController {

    @Autowired
    private IAuthService authService;
    
    @Autowired
    private IVersionRecordService versionRecordService;
    
    /**
     * 生成
     */
    @PostMapping("/create")
    public ResultData create(HttpServletRequest request, BaseUser user) {
    	user.setIp(IpUtils.getIpAddr(request));
        return authService.create(user);
    }
    
    /**
     * 下载桌面版
     */
    @PostMapping("/download")
    public ResultData download(String platform, String arch) {
        return versionRecordService.download(platform, arch);
    }
    
}
